package com.cqcetbbs.smartlab.cqcetbbs.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cqcetbbs.smartlab.cqcetbbs.R;
import com.cqcetbbs.smartlab.cqcetbbs.javabean.HotArt;

import java.util.ArrayList;

/**
 * Created by user on 2017/10/31.
 */

public class NewlistAdapter extends BaseAdapter {

    Context context;
    private ArrayList<HotArt.DataEntity> DataArrayList;

    public NewlistAdapter(ArrayList<HotArt.DataEntity> DataArrayList, Context context) {
        this.DataArrayList = DataArrayList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return DataArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return DataArrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder mViewHolder = null;
        if (view == null) {
            mViewHolder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.newslist_item, null);
          //  mViewHolder.mytitle = view.findViewById(R.id.mv_title);
           // mViewHolder.xcriv_img = view.findViewById(R.id.xcriv_img);
            mViewHolder.tv_title = view.findViewById(R.id.tv_title);
            view.setTag(mViewHolder);
        } else {
            mViewHolder = (ViewHolder) view.getTag();
        }

       // mViewHolder.mytitle.setTitle(DataArrayList.get(i).getType());
        mViewHolder.tv_title.setText(DataArrayList.get(i).getTitle());
        //Glide.with(context).load(R.drawable.tab1).centerCrop().into(mViewHolder.xcriv_img);
        return view;
    }

    public static class ViewHolder {
        //MytitleView mytitle;
       // XCRoundRectImageView xcriv_img;
        TextView tv_title;
    }

//
//    onMyItemClickListener onMyItemClickListener;
//
//    public interface onMyItemClickListener{
//        void onMyItemClickListener();
//    }
//
//
//    public void setOnItemClickListener(onMyItemClickListener onMyItemClickListener){
//        this. onMyItemClickListener = onMyItemClickListener;
//    }

}
